import axios from 'axios'
import config from '../config'

export function createFlotilla (name, usierid) {
  let url = config.SERVER_URL + window.apiPath + '/flotillas'
  return axios.post(url, {name: name, sysUserId: usierid, responseType: 'json'})
    .then(resp => resp.data)
}

export function search (userId) {
  let url = config.SERVER_URL + window.apiPath + '/flotillas-s?query=sysUserId==' + userId
  return axios.get(url).then(resp => resp.data)
}

export function updateFlotillas (objinfo) {
  objinfo.responseType = 'json'
  let url = config.SERVER_URL + window.apiPath + '/flotillas'
  return axios.put(url, objinfo)
    .then(resp => resp.data)
}

export function deleteFlotillas (id) {
  let url = config.SERVER_URL + window.apiPath + '/flotillas/' + id
  return axios.delete(url)
    .then(resp => resp.data)
}
